package com.ketty;

import java.lang.reflect.Method;

interface Test{
   public void say();
}
interface InvokeHandler{
    Object invode(Object object, Method method,Object...obj);
}
public class ProxyDemo {
    //接口要实例化，必须创建一个类，所以产生一个匿名类
    public static void main(String[] args) {
        Test test=new Test() {
            @Override
            public void say() {

            }
        };

    }
    public Test createProxyInstance(final InvokeHandler handler, final Class<?> clazz){
        return new Test() {
            @Override
            public void say() {
                try {
                    Method sayMethod = clazz.getMethod("say");
                    handler.invode(this,sayMethod);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        };
    }
}
